﻿Imports System.Text.RegularExpressions
Imports System.Data.OleDb
Imports System.Data.SqlClient


Module ModuleTaco
    Public noLocation As Integer


    Public idClient As Integer
    Public dateDebut As DateTime
    Public idEntreprise As Integer 'no dentreprise
    Public saisie As Boolean
    Public formEnAttente As Form
    'créé le dataAdapter et la requête SQL

    Public dbVilles As New cls_taco

    Public dbProvinces As New cls_taco

    Public CN As New OleDbConnection()
    Public dsClients As New DataSet

    Public noVehiculeModifier As String

    Public noVehicule As Integer
    Public recherche As Boolean = False

    'créé le dataAdapter et la requête SQL
    Public daClients As New OleDbDataAdapter()
    Public regTel As New Regex("^(?:(?<5>[- ]?)?)?(?:(?<1>[(])?(?<AreaCode>[2-9]\d{2})(?(1)[)])(?(1)(?<2>[ ])|(?:(?<3>[-])|(?<4>[ ])))?)?(?<Prefix>[1-9]\d{2})(?(AreaCode)(?:(?(1)(?(2)[- ]|[-]?))|(?(3)[-])|(?(4)[- ]))|[- ]?)(?<Suffix>\d{4})(?:[ ]?[xXeE]?(?<Ext>\d{2,4}))?$")

    Public Function getNoRowFromNom(ByVal nomChamp As String, ByVal valeurNom As String, ByVal nomNo As String, ByVal nomTable As String) As Object

        Dim maCommande As New OleDbCommand

        Dim db = New cls_taco
        Dim requete As String
        requete = "SELECT * from " & nomTable & " where " & nomChamp & "=@valeurNom"

        maCommande.Parameters.Add("@valeurNom", OleDbType.VarChar, 50).Value = valeurNom

        maCommande.CommandText = requete
        db.defDataset(maCommande, nomTable)

        If db.ds.tables(nomTable).rows.count > 0 Then
            Return nvl(db.ds.tables(nomTable).rows(0).Item(nomNo), "")

        End If
        Return 0
    End Function

    Public Function getProvince(ByVal codeDeProvince As String) As String
        Dim nomProvince As String
        Dim dbCodeProv = New cls_taco


        dbCodeProv.defDataset("SELECT nomProvince from tblProvinces where CodeProvince='" & codeDeProvince & "'", "tblProvinces")

        nomProvince = nvl(dbCodeProv.ds.Tables("tblProvinces").Rows(0).Item("nomProvince"), "")
        Return nomProvince
    End Function

    Public Function firstLetterCap(ByVal chaine As String) As String

        Return UCase(chaine.Substring(0, 1)) + LCase(chaine.Substring(1, chaine.Length - 1))
    End Function

    Function nvlReturn(ByVal obj As Object, ByVal returnValue As Object) As Object
        If IsDBNull(obj) Or obj = Nothing Then
            Return returnValue
        Else
            Return obj
        End If

        Return 0
    End Function

    Public Sub ajouterCategorie(ByVal nomCategorie As String, ByVal prcVoitureDepot As Single, ByVal montantDepot As Single, ByVal coutSurchargeKm As Single, ByVal coutLocationJour As Single, ByVal assurance As Single, ByVal kmAvantSurcharge As Single, ByVal commentaire As String)
        Dim lNewRow As DataRow
        Dim db As New cls_taco

        db.defDataset("SELECT * from tblCategories", "tblCategories")
        lNewRow = db.ds.Tables("tblCategories").NewRow

        lNewRow("noCategorie") = createNewNo("noCategorie", "tblCategories")
        lNewRow("nomCategorie") = nomCategorie
        lNewRow("prcVoitureDepot") = nvlReturn(prcVoitureDepot, DBNull.Value)
        lNewRow("montantDepot") = nvlReturn(montantDepot, DBNull.Value)
        lNewRow("coutSurchargeKm") = nvlReturn(coutSurchargeKm, DBNull.Value)
        lNewRow("coutLocationJour") = nvlReturn(coutLocationJour, DBNull.Value)
        lNewRow("assurance") = nvlReturn(assurance, DBNull.Value)
        lNewRow("kmAvantSurcharge") = nvlReturn(kmAvantSurcharge, DBNull.Value)
        lNewRow("commentaire") = nvlReturn(commentaire, DBNull.Value)

        db.ds.Tables.Item(0).Rows.Add(lNewRow)
        db.update("tblCategories")

    End Sub

    Public Sub ajouterOption(ByVal nomOption As String, ByVal description As String)
        Dim lNewRow As DataRow
        Dim db As New cls_taco

        db.defDataset("SELECT * from tblOptions", "tblOptions")
        lNewRow = db.ds.Tables("tblOptions").NewRow

        lNewRow("noOption") = createNewNo("noOption", "tblOptions")
        lNewRow("nomOption") = nomOption
        lNewRow("descriptionOption") = description

        db.ds.Tables.Item(0).Rows.Add(lNewRow)
        db.update("tblOptions")

    End Sub

    Public Function getCodeProv(ByVal nomProvince As String) As String
        Dim codeProvince As String
        Dim dbProv = New cls_taco


        dbProv.defDataset("SELECT codeProvince from tblProvinces where nomProvince='" & nomProvince & "'", "tblProvinces")

        codeProvince = nvl(dbProv.ds.Tables("tblProvinces").Rows(0).Item("codeProvince"), "")
        Return codeProvince
    End Function

    Public Function getEntreprise(ByVal noEntreprise As Integer, ByVal parametre As String) As String
        Dim returnValue As String
        Dim dbEntreprise = New cls_taco
        dbEntreprise.defDataset("select " & parametre & " from tblEntreprises where noEntreprise = " & noEntreprise & ";", "tblEntreprises")
        If dbEntreprise.ds.Tables("tblEntreprises").Rows.count > 0 Then
            returnValue = nvl(dbEntreprise.ds.Tables("tblEntreprises").Rows(0).Item(parametre), "")
        Else
            returnValue = ""
        End If

        Return returnValue
    End Function

    Public Function getNoEntreprise(ByVal nomEntreprise As String, ByVal strAdresse As String) As String
        Dim noEntreprise As Integer
        Dim dbEntreprise = New cls_taco

        Dim requete As String = "select noEntreprise from tblEntreprises where adresse = @adresse and nom = @nomEntreprise "
        Dim maCommande As New OleDbCommand

        maCommande.Parameters.Add("@adresse", OleDbType.VarChar, 80).Value = strAdresse
        maCommande.Parameters.Add("@nomEntreprise", OleDbType.BSTR, 50).Value = nomEntreprise

        maCommande.CommandText = requete

        dbEntreprise.defDataset(maCommande, "tblEntreprises")


        If dbEntreprise.ds.Tables("tblEntreprises").rows.count > 0 Then
            noEntreprise = dbEntreprise.ds.Tables("tblEntreprises").Rows(0).Item("noEntreprise")

        Else
            noEntreprise = 0
        End If


        Return noEntreprise
    End Function

    Public Sub remplirListCbo(ByVal element As String, ByVal premierChoix As String, ByVal cbo As ComboBox, Optional ByVal requeteComplement As String = "")
        'créé la connection à la base de données
        Dim dbVillesEtProvince As New cls_taco

        Dim requete As String = ""
        Select Case element
            Case "ville"
                requete = "SELECT distinct v.nomVille from tblVilles as v, tblProvinces as p"
            Case "province"
                requete = "SELECT distinct p.nomProvince from tblProvinces as p, tblVilles as v"
        End Select

        dbVillesEtProvince.defDataset(requete & requeteComplement, "tblCombo")

        cbo.Items.Clear()
        If premierChoix <> "" Then
            cbo.Items.Add(premierChoix)
        End If

        For Each ligne As DataRow In dbVillesEtProvince.ds.Tables("tblCombo").Rows
            If ligne.Item(0) <> premierChoix And ligne.Item(0) <> "" Then ''pour ne pas ajouter un doublon
                cbo.Items.Add(ligne.Item(0))
            End If
            ' MsgBox(ligne.Item(0).ToString)
        Next

        cbo.Text = cbo.Items(0)
    End Sub


    Public Function calcul_age(ByVal dateDeNaissance As DateTime)

        Dim datetimenow = DateTime.Now

        Dim age As Integer


        age = CInt(Now.Year - dateDeNaissance.Year)
        If (dateDeNaissance.Month > Now.Month) Then

            age = age - 1
        End If
        If ((dateDeNaissance.Month = Now.Month) And (dateDeNaissance.Day > Now.Day)) Then

            age = age - 1
        End If


        Return age

    End Function

    Public Sub ajouterClients(ByVal codepostal As Object, ByVal codeprovince As Object, ByVal nopermisconduire As Object, ByVal nas As Object, ByVal cell As Object, ByVal nom As Object, ByVal prenom As Object _
   , ByVal courriel As Object, ByVal datenaissance As DateTime, ByVal adresse As Object, ByVal ville As Object, ByVal telephone As Object, ByVal actif As Boolean, ByVal typeClient As Object, ByVal personne As Object, ByVal poste As Object, ByVal noEntreprise As Integer, ByVal accident As Boolean, ByVal responsable As Boolean, ByVal commentaire As String)
        Dim lNewRow As DataRow
        Dim db As New cls_taco


        db.defDataset("SELECT * from tblClients", "tblClients")


        lNewRow = db.ds.Tables("tblClients").NewRow

        lNewRow("noClient") = createNewNo("noClient", "tblClients")
        lNewRow("noPermisConduire") = nopermisconduire
        lNewRow("NAS") = nas
        lNewRow("nom") = nom
        lNewRow("prenom") = prenom
        lNewRow("dateNaissance") = datenaissance
        lNewRow("adresse") = adresse
        lNewRow("codePostal") = codepostal
        lNewRow("ville") = ville
        lNewRow("CodeProvince") = codeprovince
        lNewRow("telephone") = telephone
        lNewRow("cellulaire") = cell
        lNewRow("courriel") = courriel
        lNewRow("typeClient") = typeClient
        If noEntreprise <> 0 Then
            lNewRow("noEntreprise") = noEntreprise
        Else
            lNewRow("noEntreprise") = DBNull.Value
        End If
        lNewRow("personneContact") = personne
        lNewRow("postePersonneContact") = poste
        lNewRow("accidentDerniereAnnee") = accident
        lNewRow("responsable") = responsable
        lNewRow("actif") = actif
        lNewRow("commentaire") = commentaire

        db.ds.Tables.Item(0).Rows.Add(lNewRow)
        db.update("tblClients")

    End Sub

    Public Sub ajouterEntreprises(ByVal codepostal As Object, ByVal codeprovince As Object, ByVal nom As Object _
  , ByVal adresse As Object, ByVal ville As Object, ByVal telephone As Object, ByVal actif As Boolean, ByVal commentaire As String)
        Dim lNewRow As DataRow
        Dim db As New cls_taco

        db.defDataset("SELECT * from tblEntreprises", "tblEntreprises")


        lNewRow = db.ds.Tables("tblEntreprises").NewRow

        lNewRow("nom") = nom
        lNewRow("adresse") = adresse
        lNewRow("codePostal") = codepostal
        lNewRow("ville") = ville
        lNewRow("CodeProvince") = codeprovince
        lNewRow("telephone") = telephone
        lNewRow("noEntreprise") = createNewNo("noEntreprise", "tblEntreprises")
        lNewRow("actif") = actif
        lNewRow("commentaire") = commentaire

        db.ds.Tables.Item(0).Rows.Add(lNewRow)
        db.update("tblEntreprises")

    End Sub

    Public Sub ajouterClientLstNoire(ByVal dateDeb As DateTime, ByVal noClient As Integer, ByVal duree As Integer, ByVal commentaire As String)
        Dim lNewRow As DataRow
        Dim db As New cls_taco

        db.defDataset("SELECT * from tblListeNoire", "tblListeNoire")


        lNewRow = db.ds.Tables("tblListeNoire").NewRow


        lNewRow("commentaire") = commentaire
        lNewRow("noClient") = noClient
        lNewRow("dateDebut") = dateDeb
        lNewRow("duree") = duree


        db.ds.Tables.Item(0).Rows.Add(lNewRow)
        db.update("tblListeNoire")

    End Sub

    Public Function createNewNo(ByVal no As String, ByVal tbl As String) As Integer
        Dim num As Integer

        Dim dbClients = New cls_taco

        Dim requete As String = "select max(" & no & ") as maximum from " & tbl


        dbClients.defDataset(requete, tbl)


        num = nvl(dbClients.ds.Tables(tbl).Rows(0).Item("maximum"), Nothing)

        Return num + 1
    End Function

    Public Sub ajouterVilles(ByVal nomville As String, ByVal codeprovince As String)
        Dim lNewRow As DataRow
        Dim db As New cls_taco

        db.defDataset("SELECT * from tblVilles", "tblVilles")

        lNewRow = db.ds.Tables("tblVilles").NewRow

        lNewRow("nomVille") = nomville
        lNewRow("CodeProvince") = codeprovince

        db.ds.Tables.Item(0).Rows.Add(lNewRow)
        db.update("tblVilles")

    End Sub

    Function villeExiste(ByVal ville As String) As Boolean

        Dim dbVilles = New cls_taco
        Dim maCommande As New OleDbCommand
        Dim requete As String = "SELECT nomVille from tblVilles where nomVille = @ville"

        maCommande.Parameters.Add("@ville", OleDbType.VarChar, 80).Value = ville
        maCommande.CommandText = requete

        dbVilles.defDataset(maCommande, "tblVilles")

        Return (dbVilles.ds.Tables("tblVilles").Rows.count > 0)
    End Function

    Public Sub changerDureeListeNoire(ByVal nvDuree As Integer, ByVal datedebut As DateTime, ByVal noClient As Integer)

        Dim dbNoir = New cls_taco
        Dim maCommande As New OleDbCommand
        Dim requete As String = "SELECT * from tblListeNoire where noClient = @noClient and dateDebut=@dateDebut"

        maCommande.Parameters.Add("@noClient", OleDbType.Integer, 80).Value = noClient
        maCommande.Parameters.Add("@dateDebut", OleDbType.Date, 80).Value = datedebut
        maCommande.CommandText = requete

        dbNoir.defDataset(maCommande, "tblListeNoire")

        For Each clientNoir As DataRow In dbNoir.ds.Tables("tblListeNoire").Rows

            clientNoir.Item("duree") = nvDuree
        Next

        dbNoir.update("tblListeNoire")
    End Sub

    Function nvl(ByVal obj As Object, ByVal returnValue As Object) As Object
        If IsDBNull(obj) Or Nothing Then
            Return returnValue
        Else
            Return obj
        End If

        Return 0
    End Function

    Public Function getParam(ByVal nomParam As String) As Single

        Dim dbParam = New cls_taco

        dbParam.defDataset("SELECT * from tblParametres where dateParam >= all(select dateParam from tblParametres) ", "tblParametres")

        With dbParam.ds.Tables("tblParametres")


            For ctr As Integer = 0 To .Columns.Count - 1
                If .Columns(ctr).columnName = "parametre" Then
                    For Each RowParametre As DataRow In .rows

                        'MsgBox(RowParametre.Item("parametre"))
                        If RowParametre.Item("parametre") = nomParam Then
                            Return nvl(RowParametre.Item("valeur"), 0)
                        End If
                    Next
                End If

            Next

        End With


        Return -1
    End Function

    Public Function getDateDernierParam() As DateTime

        Dim dbParam = New cls_taco

        dbParam.defDataset("SELECT dateParam from tblParametres where dateParam >= all(select dateParam from tblParametres) ", "tblParametres")

        If dbParam.ds.Tables("tblParametres").Rows.count > 0 Then
            Return nvl(dbParam.ds.Tables("tblParametres").Rows(0).Item("dateParam"), Now.Date)
        End If

        Return Now.Date
    End Function

    Public Sub ajouterParam(ByVal dateParam As DateTime, ByVal nomParam As String, ByVal valeurParam As Single)
        Dim lNewRow As DataRow
        Dim db As New cls_taco

        db.defDataset("SELECT * from tblParametres", "tblParametres")


        lNewRow = db.ds.Tables("tblParametres").NewRow


        lNewRow("dateParam") = dateParam
        lNewRow("valeur") = valeurParam
        lNewRow("parametre") = nomParam


        db.ds.Tables.Item(0).Rows.Add(lNewRow)
        db.update("tblParametres")

    End Sub

    Public Function ObjHasNoIn(ByVal noUnique As Integer, ByVal nomNumero As String, ByVal tbl As String, Optional ByVal actif As Boolean = False) As Boolean

        Dim dbCar = New cls_taco
        Dim complement As String = ""

        If actif = True Then complement = " and actif = true"

        dbCar.defDataset("SELECT * from " & tbl & " where " & nomNumero & "=" & noUnique & complement, tbl)

        If dbCar.ds.Tables(tbl).Rows.count > 0 Then
            Return True
        Else
            Return False
        End If

    End Function

    Public Function validerTel(ByVal tel As String, ByRef messageErreur As String, Optional ByVal acceptNothing As Boolean = False) As Boolean
        Dim valide As Boolean = Regex.IsMatch(tel, "^[0-9]{3} [0-9]{3}-[0-9]{4}$") Or (acceptNothing = True And tel = "")
        If Not valide Then
            messageErreur += " - Le telephone n'est pas entré correctement, format: 999 999-9999"


        End If
        Return valide

    End Function

    Public Function validerCodePostal(ByVal codePostal As String, ByRef messageErreur As String, Optional ByVal acceptNothing As Boolean = False) As Boolean
        Dim valide As Boolean = Regex.IsMatch(codePostal, "^[aAbBcCeEgGhHjJkKlLmMnNpPrRsStTvVxXyY][0-9][aAbBcCeEgGhHjJkKlLmMnNpPrRsStTvVwWxXyYzZ]( )[0-9][aAbBcCeEgGhHjJkKlLmMnNpPrRsStTvVwWxXyYzZ][0-9]$") Or (acceptNothing = True And codePostal = "")

        If Not valide Then
            messageErreur += " - Le code postal n'est pas entré correctement, format: LCL CLC"

        End If

        Return valide
    End Function

    Public Function validerEmail(ByVal email As String, ByRef messageErreur As String, Optional ByVal acceptNothing As Boolean = False) As Boolean
        Dim valide As Boolean = Regex.IsMatch(email, "^[\w\.\-]+@[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]{1,})*(\.[a-zA-Z]{2,3}){1,2}$") Or (acceptNothing = True And email = Nothing)
        If Not valide Then
            messageErreur += " - L'email entré est invalide"

        End If

        Return valide
    End Function

    Public Function validerAdresse(ByVal strAdresse As String, ByRef messageErreur As String, Optional ByVal acceptNothing As Boolean = False) As Boolean
        Dim valide As Boolean = Regex.IsMatch(strAdresse, "^[1-9][0-9]*\s[\-\'A-ZÀÂÄÉÈÊËÌÎÏÒÔÖÙÛÜÇa-zàâäéèêëìîïòôöùûüç\s]+[0-9]*$") Or (acceptNothing = True And strAdresse = Nothing)
        If Not valide Then
            messageErreur += " - L'adresse entrée est invalide, format: noCivique, Rue App. noAppartement"
        End If
        Return valide
        ' "[0-9]+\s+([a-zA-Z]+|[a-zA-Z]+\s[a-zA-Z]+)(\s[0-9]*)?
        '"[1-9][0-9]*,\s[A-ZÀÂÄÉÈÊËÌÎÏÒÔÖÙÛÜÇ][a-zàâäéèêëìîïòôöùûüç]+(\.)?([-\s][A-ZÀÂÄÉÈÊËÌÎÏÒÔÖÙÛÜÇ][a-zàâäéèêëìîïòôöùûüç]+)*(\w)?"
    End Function

    Public Function validerNas(ByVal leNas As String, ByRef messageErreur As String, Optional ByVal acceptNothing As Boolean = False) As Boolean
        Dim valide As Boolean = Regex.IsMatch(leNas, "[0-9]{3} [0-9]{3} [0-9]{3}") Or (acceptNothing = True And leNas = Nothing)
        If Not valide Then
            messageErreur += " - Le no d'assurance social entrée est invalide, format: 999 999 999"
        End If
        Return valide
    End Function

    Public Function validerNoPermis(ByVal noPermis As String, ByRef messageErreur As String, Optional ByVal acceptNothing As Boolean = False) As Boolean
        Dim valide As Boolean = Regex.IsMatch(noPermis, "[A-Z][0-9]{4}-[0-9]{6}-[0-9]{2}") Or (acceptNothing = True And noPermis = Nothing)
        If Not valide Then
            messageErreur += " - Le no de permis de conduire est invalide, format: C9999-999999-99"
        End If
        Return valide
    End Function

    Public Function validerNom(ByVal nom As String, ByRef messageErreur As String, Optional ByVal acceptNothing As Boolean = False) As Boolean 'n'importe quel nom

        ' Return nom <> "" And nom <> " " And Not nom.Contains("  ")
        '^[A-ZÀÂÄÉÈÊËÌÎÏÒÔÖÙÛÜÇ][a-zàâäéèêëìîïòôöùûüç]+$
        Dim valide As Boolean = Regex.IsMatch(nom, "^[A-ZÀÂÄÉÈÊËÌÎÏÒÔÖÙÛÜÇa-zàâäéèêëìîïòôöùûüç'\s-]+$") Or (acceptNothing = True And nom = Nothing)
        If Not valide Then
            messageErreur += " - Le nom est invalide, vérifier les caractères spéciaux"
        End If

        Return valide

    End Function

    Public Function validerDuree(ByVal duree As Object, ByRef messageErreur As String, Optional ByVal acceptNothing As Boolean = False) As Boolean 'n'importe quel nom
        Try
            If duree = Nothing And acceptNothing = False Then
                messageErreur += "Des champs obligatoire son vides! "
                Return False
            ElseIf duree = Nothing And acceptNothing = True Then
                Return True
            End If



            Dim valide As Boolean = (duree < 100000 And duree > 0)
            If Not valide Then
                messageErreur += " - La durée est invalide, (doit être entre 1 et 9999)"
            End If

            Return valide
        Catch
            messageErreur += " - La durée est invalide, (doit être entre 1 et 9999)"
            Return False

            Return False
        End Try
    End Function

    Public Function validerJour(ByVal nbJour As Object, ByRef messageErreur As String, Optional ByVal acceptNothing As Boolean = False) As Boolean 'n'importe quel nom
        Try
            If nbJour = "" Then
                messageErreur += "Des champs obligatoire son vides! "
                Return False

            End If


            Dim valide As Boolean = (nbJour < 100000 And nbJour > 0)
            If Not valide Then
                messageErreur += " - La nombre de jour est invalide, (doit être entre 1 et 9999)"
            End If

            Return valide
        Catch
            messageErreur += " - La nombre de jour est invalide, (doit être entre 1 et 9999)"
            Return False
        End Try
    End Function

    Public Function validerCout(ByVal cout As Object, ByRef messageErreur As String, Optional ByVal acceptNothing As Boolean = False) As Boolean 'n'importe quel nom
        Try
            If cout = "" Then
                messageErreur += "Des champs obligatoire son vides! "
                Return False

            End If

            Dim valide As Boolean = (cout < 100000 And cout > -1)
            If Not valide Then
                messageErreur += " - Un des coûts saisies est invalide, (doit être entre 0 et 9999)"
            End If

            Return valide
        Catch
            messageErreur += " Cout saisie invalide, vérifier le format"
            Return False
        End Try


    End Function

    Public Function validerNbFaute(ByVal nbFaute As Object, ByRef messageErreur As String, Optional ByVal acceptNothing As Boolean = False) As Boolean 'n'importe quel nom
        Try
            If nbFaute = "" Then
                messageErreur += "Des champs obligatoire son vides! "
                Return False

            End If

            Dim valide As Boolean = (nbFaute < 100000 And nbFaute > -1)
            If Not valide Then
                messageErreur += " - La nombre de fautes est invalide, (doit être entre 1 et 9999)"
            End If

            Return valide
        Catch
            messageErreur += " - La nombre de fautes est invalide, (doit être entre 1 et 9999)"
            Return False
        End Try
    End Function

    Public Function validerVille(ByVal ville As String, ByRef messageErreur As String, Optional ByVal acceptNothing As Boolean = False) As Boolean 'n'importe quel nom

        Dim valide As Boolean = ((validerNom(ville, Nothing, False) = True) And UCase(ville) <> UCase("Choisissez une province") And UCase(ville) <> UCase("Choisissez une ville"))

        If Not valide Then
            messageErreur += " - La ville ou province est invalide"
        End If

        Return valide

    End Function

    Public Function validerNomAutre(ByVal nom As String, ByRef messageErreur As String, Optional ByVal acceptNothing As Boolean = False) As Boolean 'n'importe quel nom

        ' Return nom <> "" And nom <> " " And Not nom.Contains("  ")
        '^[A-ZÀÂÄÉÈÊËÌÎÏÒÔÖÙÛÜÇ][a-zàâäéèêëìîïòôöùûüç]+$

        Dim valide As Boolean = Regex.IsMatch(nom, "^[0-9A-ZÀÂÄÉÈÊËÌÎÏÒÔÖÙÛÜÇa-zàâäéèêëìîïòôöùûüç'\s-\.]+$") Or (acceptNothing = True And nom = Nothing)
        If Not valide Then
            messageErreur += " - Le nom est invalide, vérifier les caractères spéciaux"
        End If

        Return valide

    End Function

End Module
